package com.lm.redis.example;

import redis.clients.jedis.GeoUnit;
import redis.clients.jedis.Jedis;

public class RedisGeoDistanceExample {
    public static void main(String[] args) {
        // 连接 Redis
        Jedis jedis = new Jedis("localhost", 6379);

        // 计算北京 (user1) 和上海 (user2) 之间的距离
        Double distance = jedis.geodist("users", "user1", "user2", GeoUnit.KM);  // 单位：公里
        System.out.println("Distance between user1 and user2: " + distance + " km");
    }
}
